﻿using System.Linq;
using FikriKibar.Common.Helpers;
using FikriKibar.Common.Mailing.Entities;

namespace FikriKibar.Common.Mailing.Helpers
{
    public static class EmailHelper
    {
        public static string ConvertTemplateToString(string emailTemplate, EmailRow emailRow)
        {
            return emailRow.EmailKeys.Aggregate(emailTemplate, (current, key) => StringHelper.TemplateParser(current, MessagingConstants.EmailKeyRegEx.Replace(MessagingConstants.EmailTokenName, key.Key.ToString()), key.Value));
        }
    }
}
